<?php
namespace haibao\cms\data\attendance;


class AttendanceUser extends \haibao\cms\data\BaseMysql{
	
	public function __construct(){
		parent::__construct('\haibao\cms\model\data\attendance\AttendanceUser');
	}
	
	
	public function getAttendanceUserByJobNum($jobNum){

		$sql = 'select * from AttendanceUser where JobNum=%s';
		return $this->query($sql,array($jobNum))->fetch_assoc();
	}
	
	public function subtractUserRequestTime($jobNum,$number,$field){
	
		$sql = 'update AttendanceUser set '.$field.' = '.$field.'-'.$number.' where JobNum=%s';
		return $this->query($sql,array($jobNum));
	}
	
	public function recoverUserRequestTime($jobNum,$number,$field){
	
		$sql = 'update AttendanceUser set '.$field.' = '.$field.'+'.$number.' where JobNum=%s';
		return $this->query($sql,array($jobNum));
	}
	
	public function updateAttendanceUserOverTimeHours(){

		$sql = 'update AttendanceUser set UsualOverTimeHours=%s,WeekendsOverTimeHours=%s,HolidayOverTimeHours=%s';
		$this->query($sql,array(0,0,0));
	}
	
	public function celarUserCompensationLeave(){
	
		$sql = 'update AttendanceUser set CompensationLeave=%s';
		return $this->query($sql,array(0));
	}
}